package com.rose.redis._stand_alone_cache;

import cn.hutool.cache.Cache;
import cn.hutool.cache.impl.FIFOCache;

/**
 * <p>
 * FIFO算法：先进先出算法，判断条件：删除最早的数据
 * </p>
 *
 * @author zhu.chen
 * @date 2021/1/13
 * @version 1.0
 */
public class FifoCacheTest {

    public static void main(String[] args) {

        Cache<String,String> cache = new FIFOCache<>(3);
        cache.put("a", "1");
        cache.put("b", "2");
        cache.put("c", "3");
        cache.put("d", "4");
        System.out.println(cache.get("b"));
        /**
         * {b=CacheObj [key=b, obj=2, lastAccess=1610551499481, accessCount=1, ttl=0], c=CacheObj
         * [key=c, obj=3, lastAccess=1610551499481, accessCount=0, ttl=0], d=CacheObj
         * [key=d, obj=4, lastAccess=1610551499481, accessCount=0, ttl=0]}
         */
        System.out.println(cache.toString());
    }

}
